var app =new Vue({
    el:"#container",
    data:{
        expense:[],
        icID:"",
        oldMan:""
    },
    mounted:function (){
        this.icID=getQueryString("id");
        this.expenseInfo(this.icID);
        this.oldManInfo(this.icID);
    },
    methods:{
        expenseInfo(id){
            let data=new URLSearchParams();
            data.append("icID",id);
            axios({
                method: "post",
                url: "yly-api/admin/queryExpenseByNumber",
                data: data,
                headers: {"token":localStorage.token,"url":window.location.pathname}
            }).then(function (res) {
                console.log(res.data);
                if (res.data.code==200){
                    app.expense=res.data.data;

                }else if (res.data.code==500){
                    location.href="500.html";
                }
            }).catch(function (error){
                console.log(error.response.status);
                if (error.response.status==401){
                    alert("请先登录!");
                    location.href="login.html";
                }else if (error.response.status==403){
                    alert("用户已过期，请重新登录！");
                    localStorage.token=null;
                    location.href="login.html";
                }
            });
        },
        oldManInfo(id){
            let data=new URLSearchParams();
            data.append("icID",id);
            axios({
                method: "post",
                url: "yly-api/admin/queryOldManByNumber",
                data: data,
                headers: {"token":localStorage.token,"url":window.location.pathname}
            }).then(function (res) {
                console.log(res.data);
                if (res.data.code==200){
                    app.oldMan=res.data.data;

                }else if (res.data.code==500){
                    location.href="500.html";
                }
            }).catch(function (error){
                console.log(error.response.status);
                if (error.response.status==401){
                    alert("请先登录!");
                    location.href="login.html";
                }else if (error.response.status==403){
                    alert("用户已过期，请重新登录！");
                    localStorage.token=null;
                    location.href="login.html";
                }
            });
        }
    }
});
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg); //r是一个数组
    if (r != null) return unescape(r[2]); return null;
}